package com.szy.weibo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.szy.weibo.service.Weibo;

/**
 *@author coolszy
 *@date 2011-7-28
 *@blog http://blog.csdn.net/coolszy
 */

public class WeiBoActivity extends Activity
{
	private Button btnAdd;
	private Button btnAddWithPic;

	private String accessToken;
	private String accessTokenSecret;
	
	private static final String TAG = "MainActivity";
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.weibo);
		Intent intent = getIntent();
		accessToken = intent.getExtras().getString("accessToken");
		accessTokenSecret = intent.getExtras().getString("accessTokenSecret");
		btnAdd = (Button)findViewById(R.id.btnAdd);
		btnAddWithPic = (Button)findViewById(R.id.btnAddWithPic);
		
		btnAdd.setOnClickListener(listener);
		btnAddWithPic.setOnClickListener(listener);
		
	}
	
	private OnClickListener listener = new OnClickListener()
	{
		@Override
		public void onClick(View v)
		{
			Weibo weibo = new Weibo();
			String result = "" ;
			switch (v.getId())
			{
			case R.id.btnAdd:
				result = weibo.add(accessToken,accessTokenSecret, "json", "发送微博", "127.0.0.1");
				break;
			case R.id.btnAddWithPic:
				String[] picsPath = new String[]{"/data/baidu.gif","/data/360.png"};
				result = weibo.addWithPic(accessToken, accessTokenSecret, "json", "发送带图片微博", "127.0.0.1", picsPath);
			default:
				break;
			}
			Log.i(TAG, result);
		}
	};
}
